#include <Area_Planet_A.h>

#include <World.h>

#include <Camera.h>
#include <PlayerInterface.h>

#include <glut.h>

#include <AreaLoader.h>

#include <LoadGameObject.h>
#include <SetLoadingScreen.h>
#include <ImportAreaData.h>


////////////////////////////////////////
// Objects in this area
#include <Human.h>
#include <GroundTileA.h>
#include <WallTileA.h>
#include <WallTileB.h>
#include <WallTile_H_A.h>
#include <WallTile_V_A.h>

AreaPlanetA::AreaPlanetA(World& gameworld)
:Area(gameworld)
{
}

AreaPlanetA::~AreaPlanetA()
{
}

std::string AreaPlanetA::GetName()
{
	return "AreaPlanetA";
}

void AreaPlanetA::Init()
{
	world.AddCommand( new SetLoadingScreen( &world, 1 ) );
	Global::GameWorldSize = vec2(100,100);
	
	//for(unsigned j = 0; j < 10; ++j)
	//for(unsigned i = 0; i < 10; ++i)
	//	world.AddCommand( new LoadGameObject<Rock>( this, vec2(50 + i * 5, 50 + j * 5) ) );

	std::list< ColorData > colordata;
	AreaLoader::LoadColorData("./Graphics/AreaPlanetA.bmp", colordata);

	ColorKey* key = new ColorKey();
	AddColorType((*key), 255,0,0, Human);
	AddColorType((*key), 0,255,0, WallTileA);
	AddColorType((*key), 0,254,0, WallTileB);
	AddColorType((*key), 0,253,0, WallTile_H_A);
	AddColorType((*key), 0,252,0, WallTile_V_A);
	AddColorType((*key), 100,100,100, GroundTileA);
	//AddColorType((*key), 0,0,255, EnemyShip);
	//AddColorType((*key), 0,255,0, StaticRock);
	//AddColorType((*key), 254,254,0, AreaPlanetA);
	//key.data[ Color::MakeRGB(255,0,0) ] = new ObjectCreatorType<Rock>(this);

	//AreaLoader::ImportDataToArea(this,colordata,key);
	
	world.AddCommand( new ImportAreaData( this, colordata, key ) );
	world.AddCommand( new SetLoadingScreen( &world, 0 ) );

	
	Human* r = CreateAreaObject( Human );
	r->SetPosition( vec2(5, 5) );
	External::player->SetControlTarget(r);
	r->SetSleepState(0);
}

void AreaPlanetA::UpdateArea()
{
}

void AreaPlanetA::Cleanup()
{
}

void AreaPlanetA::CustomDraw()
{

}